$OpenBSD: patch-Modules_FindJava_cmake,v 1.20 2017/04/21 18:37:43 kurt Exp $
--- Modules/FindJava.cmake.orig	Fri Jan 13 09:05:41 2017
+++ Modules/FindJava.cmake	Fri Apr 21 09:52:03 2017
@@ -72,6 +72,8 @@
 
 include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindJavaCommon.cmake)
 
+set(MODJAVA_VER $ENV{MODJAVA_VER})
+
 # The HINTS option should only be used for values computed from the system.
 set(_JAVA_HINTS)
 if(_JAVA_HOME)
@@ -89,19 +91,22 @@ list(APPEND _JAVA_HINTS
   )
 # Hard-coded guesses should still go in PATHS. This ensures that the user
 # environment can always override hard guesses.
-set(_JAVA_PATHS
-  /usr/lib/java/bin
-  /usr/share/java/bin
-  /usr/local/java/bin
-  /usr/local/java/share/bin
-  /usr/java/j2sdk1.4.2_04
-  /usr/lib/j2sdk1.4-sun/bin
-  /usr/java/j2sdk1.4.2_09/bin
-  /usr/lib/j2sdk1.5-sun/bin
-  /opt/sun-jdk-1.5.0.04/bin
-  /usr/local/jdk-1.7.0/bin
-  /usr/local/jdk-1.6.0/bin
-  )
+if(MODJAVA_VER)
+  set(_JAVA_PATHS ${LOCALBASE}/jdk-1.8.0/bin)
+else(MODJAVA_VER)
+  set(_JAVA_PATHS
+    /usr/lib/java/bin
+    /usr/share/java/bin
+    /usr/local/java/bin
+    /usr/local/java/share/bin
+    /usr/java/j2sdk1.4.2_04
+    /usr/lib/j2sdk1.4-sun/bin
+    /usr/java/j2sdk1.4.2_09/bin
+    /usr/lib/j2sdk1.5-sun/bin
+    /opt/sun-jdk-1.5.0.04/bin
+    ${LOCALBASE}/jdk-1.8.0/bin
+    )
+endif(MODJAVA_VER)
 find_program(Java_JAVA_EXECUTABLE
   NAMES java
   HINTS ${_JAVA_HINTS}
@@ -131,7 +136,7 @@ if(Java_JAVA_EXECUTABLE)
       # 2. OpenJDK 1.6
       # 3. GCJ 1.5
       # 4. Kaffe 1.4.2
-      # 5. OpenJDK 1.7.x on OpenBSD
+      # 5. OpenJDK 1.8.x on OpenBSD
       if(var MATCHES "java version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\"")
         # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer
         set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
@@ -139,7 +144,7 @@ if(Java_JAVA_EXECUTABLE)
         # Kaffe style
         set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
       elseif(var MATCHES "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+.*)\"")
-        # OpenJDK ver 1.7.x on OpenBSD
+        # OpenJDK ver 1.8.x on OpenBSD
         set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
       else()
         if(NOT Java_FIND_QUIETLY)
